/** file Converter.h
    author belot.nicolas
    An audio converter base on libsamplerate or libsoundtouch.
*/

#ifndef CONVERTER_H
#define CONVERTER_H 1

#include "Buffer.h"

#ifdef HAVE_SAMPLERATE
	#include <samplerate.h>
#endif
namespace libtrckr {
class Converter {
	public:
	Converter(double=.0,int=0);//ratio and size of output.
	Converter(const Converter&);

	~Converter();

	int inputsize() const;
	void inputsize(int);

	int outputsize() const;
	void outputsize(int);

	double ratio() const;
	void ratio(double);

	int usable() const; //return the size of the free input.

	int convert(double*,int,double*,int); //convert
	int convert(Buffer&, Buffer&);
	Converter& operator=(const Converter&);
	int pending() const;

	private:
	double *in;
	size_t insize;
	size_t infree;
	double *out;
	size_t outsize;
	size_t outend;
	#ifdef HAVE_SAMPLERATE
		SRC_STATE* info;
		SRC_DATA*  ios;
	#endif
	
};
}

#endif


